function Y=par_solver_ext2(vec,g_target2,rd_sales_h2,rd_sales_l2,range_h2,range_l2,trans_target2,basic_h2,basic_l2)

global eta lambda zeta
global chi_a nu
global epsilon beta delta delta_p
global Q alphah alphal mh ml zbar
global tau ss

options=optimoptions('fsolve','Display','off');

iota=vec(1);
mu=vec(2);
gamma_a=vec(3);
chi_b=vec(4);
rho_a=vec(5);
rho_b=vec(6);
phi=vec(7);
theta=vec(8);

gamma_b=1.6*gamma_a;

guess=[0.6,0.1,0.02,0.001,11,2,1,6,1,2,0.01];
geq_vec=@(input)geq_solver_ext(input,iota,mu,gamma_a,gamma_b,chi_b,rho_a,rho_b,phi,theta);
[answer,~,exitflag] = fsolve(geq_vec, guess, options);

iah=answer(1);
ial=answer(2);
ibh=answer(3);
ibl=answer(4);
omegah=answer(5);
omegal=answer(6);
a=answer(7);
nsa=answer(10);
nsb=answer(11);

nbah=alphah*(1-iah*Xa(omegah));
nbal=alphal*(1-ial*Xa(omegal));
nba=nbah+nbal;
nbbh=alphah*(1-ibh*Xb(omegah));
nbbl=alphal*(1-ibl*Xb(omegal));
nbb=nbbh+nbbl;

mba=phi*(nsa/nba)^nu;
msa=phi*(nba/nsa)^(1-nu);
mbb=phi*(nsb/nbb)^nu;
msb=phi*(nbb/nsb)^(1-nu);

auxh=(alphah*mh*a+alphal*ml)*(alphah*Q(1,1)+alphal*Q(2,1))/((alphah*mh+alphal*ml)*(alphah*Q(1,1)*a+alphal*Q(2,1)));
auxl=(alphah*mh*a+alphal*ml)*(alphal*Q(2,2)+alphah*Q(1,2))/((alphah*mh+alphal*ml)*(alphal*Q(2,2)+alphah*Q(1,2)*a));
gh=1+auxh*gamma_a*(iah*Xa(omegah)+(1-iah*Xa(omegah))*mba)+auxh*gamma_b*(ibh*Xb(omegah)+(1-ibh*Xb(omegah))*mbb);
gl=1+auxl*gamma_a*(ial*Xa(omegal)+(1-ial*Xa(omegal))*mba)+auxl*gamma_b*(ibl*Xb(omegal)+(1-ibl*Xb(omegal))*mbb);

g_avg=gh*(alphah*Q(1,1)+alphal*Q(2,1)/a)/(alphah*Q(1,1)+alphal*Q(2,1));
rm=beta/(g_avg^(epsilon*zeta/(lambda+zeta)));
rt=1/rm-1+delta;
w=lambda*((eta/rt)^(eta/(zeta+lambda)))*((alphah*mh+alphal*ml)*g_avg*zbar)^(zeta/(lambda+zeta));

zlbar=(alphah*mh+alphal*ml)*zbar/(alphah*mh*a+alphal*ml);
zhbar=a*zlbar;    

rd_exp_ah=(1-ss)*chi_a*(zbar^(zeta/(zeta+lambda)))*(iah^(1+rho_a))/(1+rho_a);
rd_exp_al=(1-ss)*chi_a*(zbar^(zeta/(zeta+lambda)))*(ial^(1+rho_a))/(1+rho_a);

rd_exp_bh=(1-ss)*chi_b*(zbar^(zeta/(zeta+lambda)))*(ibh^(1+rho_b))/(1+rho_b);
rd_exp_bl=(1-ss)*chi_b*(zbar^(zeta/(zeta+lambda)))*(ibl^(1+rho_b))/(1+rho_b);

rd_exp_h=rd_exp_ah+rd_exp_bh;
rd_exp_l=rd_exp_al+rd_exp_bl;

basic_h_share=rd_exp_bh/rd_exp_h;
basic_l_share=rd_exp_bl/rd_exp_l;

zhr=(alphah*Q(1,1)*zhbar+alphal*Q(2,1)*zlbar)/(alphah*Q(1,1)+alphal*Q(2,1));
zlr=(alphah*Q(1,2)*zhbar+alphal*Q(2,2)*zlbar)/(alphah*Q(1,2)+alphal*Q(2,2));

Yh=mh*gh*zhr*((eta/rt)^(eta/zeta))*((lambda/w)^(lambda/zeta));
Yl=ml*gl*zlr*((eta/rt)^(eta/zeta))*((lambda/w)^(lambda/zeta));

rd_Y_h=rd_exp_h/Yh;
rd_Y_l=rd_exp_l/Yl;

patent_count=alphah*(iah+ibh)+alphal*(ial+ibl);
trans_share=(alphah*iah*(1-Xa(omegah))+alphal*ial*(1-Xa(omegal)))*(msa*(1-((1-msa)*delta_p)^10))/((1-(1-msa)*delta_p)*patent_count)+(alphah*ibh*(1-Xb(omegah))+alphal*ibl*(1-Xb(omegal)))*(msb*(1-((1-msb)*delta_p)^10))/((1-(1-msb)*delta_p)*patent_count);


zeroes(1)=(g_target2-g_avg)/g_target2;                  
zeroes(2)=(rd_sales_h2-rd_Y_h)/rd_sales_h2;
zeroes(3)=(rd_sales_l2-rd_Y_l)/rd_sales_l2;                     
zeroes(4)=(range_h2-omegah)/range_h2;
zeroes(5)=(range_l2-omegal)/range_l2;                    
zeroes(6)=(trans_target2-trans_share)/trans_target2;
zeroes(7)=(basic_h2-basic_h_share)/basic_h2;
zeroes(8)=(basic_l2-basic_l_share)/basic_l2;
Y=zeroes*zeroes';

